package com.sddr.register.eureka.operation;

import com.sddr.base.frame.memory.ConfigMemory;
import com.sddr.base.frame.metadata.AbstractMetaDataOperation;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.cloud.netflix.eureka.EurekaServiceInstance;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 山顶洞人郑某
 * @className EurekaMetaDataOperation.java eureka元数据
 * @date 2025 06 06
 */
public class EurekaMetaDataOperation extends AbstractMetaDataOperation {



    public EurekaMetaDataOperation(Registration registration, ConfigMemory configMemory) {
        super(registration, configMemory);
    }

    /**
     * 获取元数据结果
     *
     * @param server 服务
     * @return 结果
     */
    @Override
    public Map<String, String> getMetadataFromServer(ServiceInstance server) {
        if (server instanceof final EurekaServiceInstance eurekaServiceInstance) {
            return eurekaServiceInstance.getMetadata();
        }
        return new HashMap<>(2);
    }
}
